package com.example.anpapi.entity.po.novelmodel.Chapter;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.example.anpapi.entity.po.novelmodel.Chapter.ChapterStatus;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

@TableName("chapters")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class Chapter implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 章节ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 作品ID
     */
    @TableField("novel_id")
    private Long novelId;

    /**
     * 卷ID
     */
    @TableField("volume_id")
    private Long volumeId;

    /**
     * 章节标题
     */
    @TableField("title")
    private String title;

    /**
     * 章节内容
     */
    @TableField("content")
    private String content;

    /**
     * Quill Delta格式内容
     */
    @TableField(value = "content_delta", typeHandler = JacksonTypeHandler.class)
    private Object contentDelta;

    /**
     * 字数
     */
    @TableField("word_count")
    private Integer wordCount;

    /**
     * 排序
     */
    @TableField("sort_order")
    private Integer sortOrder;

    /**
     * 状态
     */
    @TableField("status")
    private ChapterStatus status;

    /**
     * 是否免费
     */
    @TableField("is_free")
    private Boolean isFree;

    /**
     * 价格
     */
    @TableField("price")
    private BigDecimal price;

    /**
     * 阅读数
     */
    @TableField("read_count")
    private Integer readCount;

    /**
     * 点赞数
     */
    @TableField("like_count")
    private Integer likeCount;

    /**
     * 评论数
     */
    @TableField("comment_count")
    private Integer commentCount;

    /**
     * 创建时间
     */
    @TableField(value = "created_time", fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createdTime;

    /**
     * 更新时间
     */
    @TableField(value = "updated_time", fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updatedTime;

    /**
     * 发布时间
     */
    @TableField("published_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime publishedTime;

}

